package com.constant;

public class ControllerConstan {

    public static String getValue(String packageStr, String className) {
        return "package " + packageStr + ";\n" +
                "import io.swagger.annotations.Api;\n" +
                "import io.swagger.annotations.ApiOperation;\n" +
                "import org.springframework.beans.factory.annotation.Autowired;\n" +
                "import org.springframework.web.bind.annotation.*;\n" +
                "\n" +
                "/**\n" +
                " * @author EDY\n" +
                " */\n" +
                "@Api(tags = \" API\")\n" +
                "@RestController\n" +
                "@RequestMapping(\""+ className.substring(0, className.length() - "Controller".length()).toLowerCase() +"\")\n" +
                "public class " + className + " {\n" +
                "\n" +
                "    @Autowired\n" +
                "    private " + className.substring(0, className.length() - "Controller".length()) + "Service service;\n" +
                "\n" +
                "\n" +
                "    @ApiOperation(\"新增\")\n" +
                "    @PostMapping(\"insert\")\n" +
                "    public ResponseResult insert() {\n" +
                "        return service.insert();\n" +
                "    }\n" +
                "\n" +
                "    @ApiOperation(\"修改\")\n" +
                "    @PostMapping(\"update\")\n" +
                "    public ResponseResult update() {\n" +
                "        return service.update();\n" +
                "    }\n" +
                "\n" +
                "    @ApiOperation(\"删除\")\n" +
                "    @GetMapping(\"delete\")\n" +
                "    public ResponseResult delete(@RequestParam Integer id) {\n" +
                "        return service.delete(id);\n" +
                "    }\n" +
                "\n" +
                "    @ApiOperation(\"查询\")\n" +
                "    @PostMapping(\"select\")\n" +
                "    public ResponseResult select() {\n" +
                "        return service.select();\n" +
                "    }\n" +
                "}\n";
    }

}
